package com.e3.basdoc.cust.client;

import java.util.List;

import com.e3.basdoc.cust.model.CustModel;
import com.e3.basdoc.cust.model.CustQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.e3.web.widget.client.MyField;
import com.extjs.gxt.ui.client.widget.form.Field;

public class CustQueryDialog extends TGFQueryDialog<CustModel> {

	private CustRPCServiceAsync service = CustRPCService.Util.getInstance();

	@Override
	protected SuperQC getQueryCondition() {
		MyField<?> field = getMyFormField(CustModel.CODE);
		String code = (String) field.getFieldValue();
		field = getMyFormField(CustModel.NAME);
		String name = (String) field.getFieldValue();

		final CustQC qc = new CustQC();
		qc.setCode(code);
		qc.setName(name);
		
		return qc;
	}

	@Override
	protected List<Field<?>> getFormFields() {
		String[] fields = {CustModel.CODE,CustModel.NAME};
		return CustHelper.INSTANCE.getFormFields(fields);
	}

	@Override
	protected void executeQueryService(SuperQC qc,	GwtAsyncCallback<List<CustModel>> callback) {
		service.getCustsByCondition((CustQC)qc, callback);
	}

}
